In modern operating systems and run time environments it is often necessary to inspect the binary code of a computer program to, for example, insert calls to trace functions or breakpoints. This may be done by, for example, replacing an instruction in the binary code by a trap (i.e. a program interrupt) or by a call to a debug program. However, sometimes it is necessary to know something about the instruction in the binary code which is to be replaced. This is typically done by software within the debug program which replicates the function of the “instruction decoder” or Decoder Unit inside a Central Processing Unit (CPU).
The code to do the inspection of the binary code is typically similar to that in a disassembler which decodes the instructions and decides if and how they can be modified. Whenever a new instruction is added to a CPU this code for inspecting the binary code stops working and has to be modified to take account of the added instruction. This modification is necessary even if the instruction that is added is one that is simple (such as a new arithmetic or vector operation) which doesn't really need to be treated differently by the code inspecting the binary code.
Published United States patent application 2009/0063822 A1 discloses an instruction analyzing section that analyses an instruction to be processed and outputs analysis information indicating whether the instruction matches with a specific instruction that is previously defined (such as a NOP); a memory that temporarily stores the instruction with that analysis information; and a specific instruction execute controller that reads out the analysis information stored in the memory and controls operation of at least one of the instruction fetch unit and the instruction decode unit when the analysis instruction indicates that the instruction matches with the specific instruction (i.e. that it is a NOP).
Published United States patent application 2008/0307397 A1 discloses that program code is statically analyzed (without actually executing the code) including by virtually executing the code with a virtual processor or emulator that steps through the code. Programming logic errors can be located, such as calls that never return or isolated code that can never be reached.
Published United States patent application 2007/0174817 A1 discloses receiving binary code and code analysis rules. At least one code analysis rule is indicative of a query related to the functionality of the binary code. The query is implemented in analysis code configured to determine results of the query.